using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using Fan.Dongping.DataBase;


namespace Fan.Dongping.Ali.DataAccess
{
    /// <summary>
    /// 
    /// </summary>
    public class MailDA
    {


        /// <summary>
        /// 
        /// </summary>
        /// <param name="tos"></param>
        /// <param name="cc"></param>
        /// <param name="bcc"></param>
        /// <param name="subject"></param>
        /// <param name="body"></param>
        /// <returns></returns>
        public static int InsertMail(string tos, string cc, string bcc, string subject, string body)
        {
            string sql = "Insert into MailWaittingSend (MailTo,Cc,Bcc,Subject,Body,CreateTime) Values (@MailTo,@Cc,@Bcc,@Subject,@Body,GetDate())";
            SqlParameter[] para = new SqlParameter[6];
            para[1] = new SqlParameter("@MailTo", tos);
            para[2] = new SqlParameter("@Cc", cc);
            para[3] = new SqlParameter("@Bcc", bcc);
            para[4] = new SqlParameter("@Subject", subject);
            para[5] = new SqlParameter("@Body", body);

            return DA_Base.ExecuteNonQuery(sql, para);
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="toAddress"></param>
        /// <param name="subject"></param>
        /// <param name="body"></param>
        /// <returns></returns>
        public static int InsertMail(Collection<string> toAddress, string subject, string body)
        {
            string to = null;
            foreach (string t in toAddress)
            {
                to += t;
                to += ';';
            }
            return InsertMail(to, null, null, subject, body);
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="toAddress"></param>
        /// <param name="subject"></param>
        /// <param name="body"></param>
        /// <returns></returns>
        public static int InsertMail(string toAddress, string subject, string body)
        {
            return InsertMail(toAddress, null, null, subject, body);
        }



    }
}
